<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="tabmenu">
<!-- 201261220周家财修改 添加团购链接-->
  <?php include template('layout/submenu');?>
<?php if ($output['isOwnShop']) { ?>
  <a href="<?php echo urlShop('store_groupbuy', 'groupbuy_add_vr'); ?>" style="right:100px" class="ncsc-btn ncsc-btn-green" title="新增虚拟商品抢购"><i class="icon-plus-sign"></i>新增虚拟抢购</a>
  
   <a href="<?php echo urlShop('store_groupbuy', 'bef_groupbuy_add');//echo urlShop('store_groupbuy', 'groupbuy_add');?>" class="ncsc-btn ncsc-btn-green" title="<?php echo $lang['groupbuy_index_new_group'];?>">
  <i class="icon-plus-sign"> </i>
  <?php echo $lang['groupbuy_index_new_group'];?></a> 
  <?php } else { ?>

  <?php if(!empty($output['current_groupbuy_quota'])) { ?>
  <a href="<?php echo urlShop('store_groupbuy', 'groupbuy_add_vr'); ?>" style="right:200px" class="ncsc-btn ncsc-btn-green" title="新增虚拟商品抢购"><i class="icon-plus-sign"></i>新增虚拟抢购</a>
  <a href="<?php echo urlShop('store_groupbuy', 'bef_groupbuy_add');//echo urlShop('store_groupbuy', 'groupbuy_add');?>" style="right:100px" class="ncsc-btn ncsc-btn-green" title="<?php echo $lang['groupbuy_index_new_group'];?>">
  <i class="icon-plus-sign"></i>
  <?php echo $lang['groupbuy_index_new_group'];?></a>
  <a class="ncsc-btn ncsc-btn-acidblue" href="<?php echo urlShop('store_groupbuy', 'groupbuy_quota_add');?>" title="套餐续费"><i class="icon-money"></i>套餐续费</a>
  <?php } else { ?>
  <a class="ncsc-btn ncsc-btn-acidblue" href="<?php echo urlShop('store_groupbuy', 'groupbuy_quota_add');?>" title="购买套餐"><i class="icon-money"></i>购买套餐</a>
  <?php } ?>
<?php } ?>

</div><!-- 201261220周家财修改 添加团购链接-->
<form id="add_form" action="index.php?act=store_groupbuy&op=groupbuy_add" method="post" >
<table class="ncsc-default-table">
  <thead>
    <tr>
      <th class="w10"></th>
     <!--  <th class="w50"></th> -->
      <th class="w160">团购活动名称</th>
      <th class="w160">开始时间</th>
      <th class="w160">结束时间</th>
      <th class="w90">价格下限</th>
      <th class="w90">价格上限</th>
      <th class="w90">操作</th>
    </tr>
  </thead>
  <tbody>

    <?php foreach($output['range_list'] as $key=>$price){?>
    <tr class="bd-line">
      <td></td>
      <td>
         <?php echo $price['range_name'];?>
      </td>
      
      <td id='start_time'><?php echo date('Y-m-d H:i:s',$price['start_time']);?></td>
      
      <td id='end_time'><?php echo date('Y-m-d H:i:s',$price['end_time']);?></td>
      
      <td id='range_start'><?php echo $price['range_start'];?></td>
      
      <td id='range_end'><?php echo $price['range_end'];?></td>
      
      <td><input name="price_list"  type="radio" class="price_check" value="<?php echo $price['range_id'];?>" ></td>
    </tr>
    <?php }?>
   
  </tbody>
 <input type="hidden" name="start_time" value='' />
 <input type="hidden" name="end_time" value='' />
 <input type="hidden" name="range_start" value='' />  
 <input type="hidden" name="range_end" value='' /> 
</table>
<div class="bottom">
 <label style="margin-left: 70%" class="submit-border">
      <input id="price_check" class="submit" value="提交" type="submit">
  </label>
</div>
</form>
<script type="text/javascript">
$(function(){

	 $('#price_check').click(function(){
		 
			
			//return false;
	}); 


	 $('.price_check').click(function(){
			var start_time=$(this).parent().siblings('#start_time').text();
			var end_time=$(this).parent().siblings('#end_time').text();
			var range_start=$(this).parent().siblings('#range_start').text();
			var range_end=$(this).parent().siblings('#range_end').text();

			$("input[name='start_time']").val(start_time);
			$("input[name='end_time']").val(end_time);
			$("input[name='range_start']").val(range_start);
			$("input[name='range_end']").val(range_end);

			//首先判断改活动是否结束
			// 获取当前时间戳(以s为单位)
		 	var now = Date.parse(new Date());
		 	now = now / 1000;

		 	var end_time = end_time;
		 	var end_time = Date.parse(new Date(end_time));
		 	
			if(start_time==''){
				alert('请先选择团购活动');return false;
			} else if(now>end_time){
				alert('该团购活动已结束');return false;
			}  
			
		});
});

</script>

